import { Body, Controller, Get, Post, UseInterceptors } from '@nestjs/common';
import { TransformInterceptor } from 'src/interceptor/intersform.interceptor';
import { updataDataDto } from './dto/saveInfo.dto';
import { SaveInfoService } from './saveInfo.service';

@Controller('/saveInfo')
@UseInterceptors(new TransformInterceptor())
export class SaveInfoController {
  constructor(protected readonly saveInfoService: SaveInfoService) {}

  @Get()
  async getAllInfo() {
    const result = await this.saveInfoService.getAllInfo();
    return {
      data: result,
      message: '获取成功！',
    };
  }

  @Post()
  async updataInfo(@Body() data: updataDataDto) {
    const result = await this.saveInfoService.updataTable(data);
    return {
      data: result,
      message: '更新成功！',
    };
  }
}
